import React from "react";
import SearchComps from "../../components/searchComps";
class Test extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            searchComps: [{
                    comType: "input",
                    inputType: "number",
                    value: "",
                    placeholder: "门店名称/门店编码",
                    label: "门店信息"
                },
                {
                    comType: "input",
                    inputType: "text",
                    value: "",
                    placeholder: "门店名称/门店编码",
                    label: "门店信息"
                },
                {
                    comType: "input",
                    inputType: "number",
                    value: "",
                    placeholder: "门店名称/门店编码",
                    label: "门店信息"
                },
                {
                    comType: "input",
                    inputType: "text",
                    value: "",
                    placeholder: "门店名称/门店编码",
                    label: "门店信息"
                },
                {
                    comType: "select",
                    value: "",
                    placeholder: "选择品牌",
                    label: "品牌",
                    option: [{
                            label: "可乐",
                            value: 1
                        },
                        {
                            label: "百事可乐",
                            value: 2
                        },
                        {
                            label: "雪碧",
                            value: 3
                        }
                    ]
                },
                {
                    comType: "datePicker",
                    value: "",
                    placeholder: "选择日期",
                    label: "创建时间"
                },
                {
                    comType: "rangePicker",
                    value: "",
                    placeholder: "选择日期",
                    label: "创建时间"
                }
            ],
            searchParams: {}
        };
    }
    searchChange = () => {
        const searchParams = this.state.searchComps.map(item => {
            if (typeof item.value === "string") {
                return item.value.replace(/\s/g, "");
            }
            return item.value;
        });

        this.setState({
            searchParams: {
                value0: searchParams[0],
                value1: searchParams[1],
                value2: searchParams[2],
                value3: searchParams[3],
                value4: searchParams[4],
                value5: searchParams[5],
                value6: searchParams[6] && searchParams[6][0],
                value7: searchParams[6] && searchParams[6][1]
            }
        });
    };
    subSearch = () => {
        console.log(this.state.searchParams);
    };
    render() {
        return ( <
            div >
            <
            SearchComps subSearch = {
                this.subSearch
            }
            searchChange = {
                this.searchChange
            }
            searchComps = {
                this.state.searchComps
            }
            />
            测试 ss {
                " "
            } <
            /div>
        );
    }
}

export default Test;